<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@include file="../common/head.jsp"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<div class="right">
    <div class="location">
        <strong>你现在所在的位置是:</strong>
        <span>用户管理页面</span>
    </div>
    <script>
        function
    </script>
    <div class="search">
        <form method="post" action="user/show">
            <span>用户名：</span>
            <input name="userName" class="input-text" type="text" value="${param.userName }">

            <span>用户角色：</span>
            <select name="role.roleId">
                <c:if test="${requestScope.roleList != null }">
                    <option value="0">--请选择--</option>
                    <c:forEach var="role" items="${requestScope.roleList}">
                        <option <c:if test="${role.roleId==param['role.roleId'] }">selected</c:if>
                                value="${role.roleId}">${role.roleName}</option>
                    </c:forEach>
                </c:if>
            </select>

            <%--            <input type="hidden" name="pageIndex" value="1"/>--%>
            <input	value="查 询" type="submit" id="searchbutton">
            <a href="user/toAdd">添加用户</a>
        </form>
    </div>
    <c:if test="${fn:length(requestScope.pageInfo.list) == 0}">
        <h2>抱歉!未找到符合条件的查询记录</h2>
    </c:if>
    <c:if test="${fn:length(requestScope.pageInfo.list) != 0}">
        <!--用户-->
        <table class="providerTable" cellpadding="0" cellspacing="0">
            <tr class="firstTr">
                <th width="10%">用户编码</th>
                <th width="20%">用户名</th>
                <th width="10%">性别</th>
                <th width="10%">头像</th>
                <th width="10%">年龄</th>
                <th width="10%">电话</th>
                <th width="10%">用户角色</th>
                <th width="30%">操作</th>
            </tr>
            <c:forEach var="user" items="${requestScope.pageInfo.list }" varStatus="status">
                <tr>
                    <td>
                        <span>${user.userCode }</span>
                    </td>
                    <td>
                        <span>${user.userName }</span>
                    </td>
                    <td>
                                <span>
                                    <c:if test="${user.gender==1}">男</c:if>
                                    <c:if test="${user.gender==2}">女</c:if>
                                </span>
                    </td>
                    <td>
                        <c:set value="${fn:split(user.userPicName,',')}" var="arrayPic"></c:set>
                        <c:forEach items="${arrayPic}" var="picName">
                            <img src="/statics/headPic/${picName}" alt="暂无" height="50">
                        </c:forEach>

                    </td>
                    <td>
                        <span>${user.age}</span>
                    </td>
                    <td>
                        <span>${user.phone}</span>
                    </td>
                    <td>
                        <span>${user.role.roleName}</span>
                    </td>
                    <td>
                        <span><a class="viewUser" href="/user/showUser/${user.userId}"><img src="images/read.png" alt="查看" title="查看"/></a></span>
                        <c:if test="${sessionScope.user.role.roleId==1}">
                            <span><a class="modifyUser" href="user/toModify?userId=${user.userId }"><img src="images/xiugai.png" alt="修改" title="修改"/></a></span>
                            <span><a class="deleteUser" href="javascript:remove(${user.userId})"><img src="images/schu.png" alt="删除" title="删除"/></a></span>
                        </c:if>
                    </td>
                </tr>

            </c:forEach>
            <script>
                function remove(userId) {
                    var flag = confirm("您确定要删除"+userId+"号用户吗?")
                    if (flag==true){
                        window.location = "user/toRemove?userId="+userId;
                    }
                }
            </script>
        </table>
    </c:if>
    <c:import url="../common/rollpage.jsp">
        <%--        <c:param name="total" value="${requestScope.pageInfo.total}"/>--%>
        <%--        <c:param name="pageNum" value="${requestScope.pageInfo.pageNum}"/>--%>
        <%--        <c:param name="pages" value="${requestScope.pageInfo.pages}"/>--%>
    </c:import>
</div>
</section>

<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeUse">
    <div class="removerChid">
        <h2>提示</h2>
        <div class="removeMain">
            <p>你确定要删除该用户吗？</p>
            <a href="#" id="yes">确定</a>
            <a href="#" id="no">取消</a>
        </div>
    </div>
</div>

<%@include file="../common/foot.jsp" %>
